﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AvantGameMachine.Timers
{
    public class TimerManager
    {
        private List<Tempo> tempoList = new List<Tempo>();
        private long frameTime = 0;
        private DateTime timeStart;
        private TimeSpan ellapsed;

        internal TimerManager()
        {
            timeStart = DateTime.UtcNow;
        }

        public Tempo GetNewTempo(int _ellapseTime, bool _autoreset)
        {
            Tempo tmp = new Tempo(_ellapseTime, _autoreset);
            tempoList.Add(tmp);
            return tmp;
        }

        public long GlobalCurrentTime
        {
            get
            {
                ellapsed = DateTime.UtcNow - timeStart;
                return (long)ellapsed.TotalMilliseconds;
            }
        }

        public long FrameCurrentTime
        {
            get
            {
                return frameTime;
            }
        }

        internal void UpdateFrameTime()
        {
            frameTime = GlobalCurrentTime;
        }
    }
}
